import React from 'react'
import { useLocation } from 'react-router-dom'
import { Button } from 'antd-mobile'
import styles from './index.module.css'
import http from '../../utils/http'
function Index() {

  const { state } = useLocation()
  console.log(state);

  const handleadd = async () => {
    const res = await http.get('/api/pay', {
      params: {
        id: state.id,
        price: state.tick.secondTick
      }
    })

    console.log(res);

    const { code, data } = res.data

    if (code === 200) {
      window.location.href = data
    }
  }

  return (
    <div>
      <div className={styles.list_wroe}>
        <div className={styles.lists_wroe}>
          <span>{state.start}</span>
          <span>{state.startTime}</span>
          <span>{state.end}</span>
          <span>商务座 <b>有票</b></span>
          <span>一等座 <b>有票</b></span>
          <span>二等座 <b>有票</b></span>
        </div>
        <div className={styles.listss_wroe}>
          {state.tick.secondTick}
        </div>
      </div>
      <div>
        <Button block color='primary' size='large' onClick={() => handleadd()}>
          去支付
        </Button>
      </div>
    </div>
  )
}

export default Index
